import * as ENUM from './all'

export function useEnum(key?: string) {
  /**
   * 获取列表
   */
  const useEnumList = () => ENUM[key]
  /**
   * 获取枚举对象
   */
  const useEnumItem = (value: number | string) => {
    const list = useEnumList()
    // 根据value获取对应数据
    const data = list.find((item) => item.value === value)
    return data || null
  }

  return {
    useEnumList,
    useEnumItem,
  }
}
